# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libmowgli
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.0.0
pkgrel=3
pkgdesc="Performance and usability-oriented extensions to C (mingw-w64)"
arch=('any')
url="http://www.atheme.org/project/mowgli"
license=('GPL')
depends=("${MINGW_PACKAGE_PREFIX}-openssl")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "git")
options=('staticlibs' 'strip')
source=(#"${_realname}-${pkgver}::git+https://github.com/atheme/libmowgli-2.git#tag=${_realname}-${pkgver}"
        https://github.com/atheme/libmowgli-2/archive/${_realname}-${pkgver}.tar.gz
        libmowgli-2.0.0-mingw-have-declarations.patch)
sha256sums=('fd48e74f1f706b436e0f25c3d3d63753e9c066ef88e662cd34303ccd3b780798'
            '5c5bdc96e2c1f2d147afe0f806b395096d9deaa9cdd42f523d944adcd3c5707f')

prepare() {
  cd ${srcdir}/${_realname}-2-${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/libmowgli-2.0.0-mingw-have-declarations.patch

  #autoreconf -fi
}

build() {
  cp -rf ${_realname}-2-${_realname}-${pkgver} ${srcdir}/build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}
  ./configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-shared \
    --enable-static

  make
}

package() {
  cd ${srcdir}/build-${MINGW_CHOST}
  make DESTDIR="${pkgdir}" install
  install -D -m644 COPYING "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
